<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <!-- 
        3. 至少使用2种方式实现以下data数据的深拷贝
     -->
</head>
<body>
    <script>
        const data = [{
            id: 1,
            name: 'Huawei Mate50 pro',
            price: 6998
        }, {
            id: 2,
            name: 'Apple 18',
            price: 12998
        }, {
            id: 3,
            name: 'xiaomi 12',
            price: 3998
        }]
    
    // 1.用JSON进行数组对象的深拷贝
        const result =  data.map(function(item){
            return JSON.parse(JSON.stringify(item)) 
        })
        result[0].price = 9999
        // console.log(data,result)

    // 2.Object.assign()
        const result2 =  data.map(function(item){
            return  Object.assign({},item)
        })
        result2[0].price = 9999
        // console.log(data,result2)

    // 3.用jQuery的extend方法实现深拷贝
       
    </script>
</body>
</html>